# Little HTMX Book
(v2.0.4, Updated April 2025)
AUTHOR: Alex Pineda @ShipWithAlex
# 1 Introduction: HTMX and Modern Web Development
This book covers:
- How HTMX works and when to use it
- Practical examples and patterns
- Backend integration techniques
Start with a blank index.html file and copy the examples. Let’s skip the hype and focus on the tech, shall we?
## 1.1 HTMX vs Other Libraries
HTMX differs from other frontend tools:
- React/Vue/Angular: HTMX enhances HTML directly, requiring less JavaScript than these SPA frameworks.
- Alpine.js: While Alpine.js handles client-side interactivity, HTMX focuses on server communication and DOM updates.
- Vanilla JavaScript: HTMX eliminates boilerplate for AJAX requests and DOM manipulation.
[](https://www.treesnap.app)
# 2 Getting Started with HTMX
This chapter introduces the fundamentals of HTMX. It covers setting up HTMX in a project and creating the first HTMX-powered element. By the end, you’ll have a functional HTMX setup and understand its basic implementation.
## 2.1 Setup
Add HTMX to your project via CDN:
```
```
Alternatively, install via npm: `npm install htmx.org`
## 2.2 Your first HTMX-powered element
Now that we have HTMX in our project, let’s create our first HTMX-powered element. We’ll start with a simple button that loads some content when clicked.
Here’s our HTML:
```
```
Let’s break this down:
- We have a button element with two HTMX attributes: `hx-get` and `hx-target`.
- `hx-get="/api/hello"` tells HTMX to make a GET request to the “/api/hello” URL when the button is clicked.
- `hx-target="#message"` specifies that the response should be inserted into the element with the id “message”.
When you click this button, HTMX will make a GET request to “/hello” and put the response into the div with id “message”.
Behind the scenes, HTMX is setting up an event listener on the button. When clicked, it makes an AJAX request and updates the DOM with the response. Easy!
## 2.3 Understanding the HTMX attribute syntax
HTMX uses HTML attributes to define behavior. The general syntax is:
```
hx-{action}="{value}"
```
Let’s look at some common attributes:
### 2.3.1 hx-get: Makes a GET request
```
```
### 2.3.2 hx-post: Makes a POST request
```
```
### 2.3.3 hx-trigger: Specifies when to trigger the request
```
```
### 2.3.4 hx-target: Specifies where to put the response
```
This is the message box
```
### 2.3.5 hx-swap: Defines how the response should be swapped in
```
Old content
```
### 2.3.6 hx-vals: Adds extra values to the request
```
```
These attributes give you powerful control over your web application’s behavior, all from within your HTML.
HTMX Attributes provide functionality for:
- Making various types of HTTP requests (GET, POST, PUT, PATCH, DELETE)
- Specifying triggers for actions
- Targeting elements for updates
- Controlling how content is swapped
- Managing URL history
- Handling form submissions
- Adding custom headers and parameters
- Managing indicators and loading states
- Interacting with server-sent events and WebSockets
- And more
Let’s put it all together with a small project: a simple dynamic content loader.
```
Dynamic Content Loader
Loading...
```
This example demonstrates:
1. Using `hx-get` to make a GET request
2. Using `hx-target` to specify where the response should be inserted
3. Using `hx-trigger` to define when the request should be made
4. Using `hx-indicator` to show a loading state
On the server side (using Express.js), you might have:
```
const express = require('express');
const app = express();
const quotes = [
"The only way to do great work is to love what you do. - Steve Jobs",
"Innovation distinguishes between a leader and a follower. - Steve Jobs",
"Stay hungry, stay foolish. - Steve Jobs"
];
app.get('/api/quote', (req, res) => {
const randomQuote = quotes[Math.floor(Math.random() * quotes.length)];
res.send(`
${randomQuote}
`);
});
app.listen(3000, () => console.log('Server running on port 3000'));
```
This server randomly selects a quote and sends it back to the client, demonstrating a simple dynamic content loading scenario with HTMX.
# 3 HTMX Core Concepts
In this chapter, we’ll explore more of the core concepts in depth.
## 3.1 Triggers: Making Things Happen
In HTMX, triggers are what set things in motion. They define when an HTMX request should be made. By default, the trigger depends on the element:
- For forms, it’s the submit event
- For inputs, selects, and textareas, it’s the change event
- For everything else, it’s the click event
But HTMX gives you the flexibility to change this using the `hx-trigger` attribute. Let’s look at some examples:
```
```
From simple events to timed intervals and even combinations of triggers, HTMX “got you bro”.
## 3.2 Targets: Where the Magic Appears
When HTMX makes a request, it needs to know where to put the response. This is where targets come in. By default, HTMX will replace the innerHTML of the element that triggered the request. But often, you’ll want to update a different part of your page.
The `hx-target` attribute allows you to specify exactly where the response should go. Here are a few ways to use it:
```
```
With `hx-target`, you have precise control over where your dynamic content appears.
## 3.3 Swapping: Seamless Content Updates
Once HTMX knows where to put the response, it needs to know how to put it there. This is where swapping comes in. By default, HTMX will replace the innerHTML of the target element, but you have many other options using the `hx-swap` attribute:
```
```
HTMX also provides transition options for smooth animations:
```
```
## 3.4 Indicators: Keeping Users in the Loop
When making asynchronous requests, it’s important to keep your users informed about what’s happening. HTMX makes this easy with indicators. By default, HTMX will add an `htmx-request` class to the triggering element during a request. You can use this to show a loading spinner or change the appearance of the element.
For more control, you can use the `hx-indicator` attribute:
```
```
In this example, the spinner image will only be visible during the HTMX request.
These core concepts - triggers, targets, swapping, and indicators - form the foundation of HTMX. By combining them in different ways, you can create rich, interactive web applications with ease. In the next chapter, we’ll look at how to level up your HTMX skills with more advanced techniques.
# 4 Error Handling
HTMX provides three main error handling mechanisms:
## 4.1 Application Errors
Handle form validation and business logic errors through server-side rendering:
```
```
Server-side (pseudo-code):
```
if email is invalid:
return render_template('form.html', errors={'email': 'Invalid email'})
else:
# process form
```
For a more detailed example, refer to the [HTMX inline validation example](https://htmx.org/examples/inline-validation/).
## 4.2 Server Errors
Customize handling of HTTP error codes (404, 500, etc.):
```
htmx.on('htmx:beforeSwap', function(evt) {
if (evt.detail.xhr.status === 404) {
evt.detail.shouldSwap = true;
evt.detail.target = htmx.find('#error-container');
}
});
```
## 4.3 Network Errors
Handle connection issues with event listeners:
```
htmx.on('htmx:sendError', function(evt) {
htmx.find('#error-message').innerHTML = 'Request failed';
});
```
## 4.4 Special Consideration: 422 Responses
By default, HTMX doesn’t swap content for 422 (Unprocessable Entity) responses. If your server-side framework uses this status code for application-level errors, you may want to modify this behavior:
```
htmx.config.swapStatusCodes.push(422);
```
Note: HTMX eliminates the need for Post-Redirect-Get patterns since AJAX operations don’t affect browser history.
See the [HTMX inline validation example](https://htmx.org/examples/inline-validation/) for more details.
# 5 Leveling Up Your HTMX Skills
Now that you’ve got a handle on the basics, it’s time to take your HTMX skills to the next level. In this chapter, we’ll explore some more advanced techniques that will help you create more dynamic and responsive web applications.
## 5.1 HTMX and Forms
Let’s look at how HTMX can enhance your form handling:
### 5.1.1 Basic Form Submission
Here’s a simple HTMX-powered form:
```
```
When this form is submitted, HTMX will:
1. Serialize the form data
2. Send a POST request to “/api/echo”
3. Update the `#result` div with the server’s response
All without a page reload!
### 5.1.2 Real-time Form Validation
HTMX can also handle real-time form validation:
```
```
In this example, when the email input changes, after a 200ms delay, HTMX will send a POST request to “/api/validate-email” and put the result in the next `.error` div. This allows for immediate feedback without waiting for form submission.
## 5.2 Boosting Performance with Lazy Loading
Lazy loading is a technique to defer the loading of non-critical resources, improving initial load time. HTMX makes implementing lazy loading straightforward:
```
```
The `hx-trigger="revealed"` attribute tells HTMX to make the request when the element comes into view. This is perfect for implementing infinite scroll or loading comments only when needed.
## 5.3 Creating Smooth Transitions and Animations
HTMX provides built-in support for animations through CSS transitions. Here’s how you can create a fade effect:
```
```
The `transition:true` in the `hx-swap` attribute tells HTMX to use a smooth transition when swapping content. HTMX will add the `htmx-added` class to new content, triggering our fade-in effect.
### 5.3.1 Complex Animations with CSS Classes
HTMX works well with more complex CSS animations. You can use the htmx-added and htmx-settling classes for sophisticated effects:
```
.fancy-transition {
transition: all 0.5s ease-out;
transform: translateY(20px);
opacity: 0;
}
.fancy-transition.htmx-added {
transform: translateY(0);
opacity: 1;
}
```
### 5.3.2 Animating Multiple Elements with hx-swap-oob
The hx-swap-oob (out-of-band) attribute allows you to animate multiple elements simultaneously:
```
```
Your server response can include updates for both the main content and the sidebar, allowing for coordinated animations across different parts of your page.
### 5.3.3 Custom Animations with HTMX Events
HTMX events allow you to trigger custom animations at specific points in the request lifecycle:
```
htmx.on('htmx:afterSwap', function(event) {
if (event.detail.target.id === 'animated-element') {
anime({
targets: '#animated-element',
translateX: 250,
rotate: '1turn',
duration: 800
});
}
});
```
This example uses the Anime.js library to create a custom animation after content is swapped.
## 5.4 Putting It All Together
Let’s combine these techniques into a more complex example - a live search feature:
```
```
This example demonstrates:
1. Real-time search as the user types
2. Debouncing to reduce unnecessary requests
3. A loading indicator
4. Smooth transitions for results
5. Error handling (via the `htmx:afterRequest` event)
By leveraging these advanced HTMX techniques, you can create rich, interactive web applications with minimal JavaScript. In the next chapter, we’ll explore even more advanced concepts to further enhance your HTMX skills.
# 6 Advanced HTMX Techniques
As you become more comfortable with HTMX, you’ll want to explore its more advanced features. This chapter will introduce you to some powerful techniques that can take your web applications to the next level.
## 6.1 Server-Sent Events: Real-Time Updates
Server-Sent Events (SSE) allow the server to push data to the client in real-time. HTMX makes it easy to set up SSE connections:
```
```
In this example, HTMX establishes an SSE connection to `/api/events`. When the server sends a “message” event, HTMX will swap the content of the inner div.
Here’s a simple Python server implementation using Flask:
```
from flask import Flask, Response
import time
app = Flask(__name__)
@app.route('/api/events')
def sse():
def event_stream():
while True:
time.sleep(1)
yield f"data: The time is {time.time()}\n\n"
return Response(event_stream(), content_type='text/event-stream')
```
This creates a simple event stream that sends the current time every second.
## 6.2 HTMX Extensions: Expanding Functionality
HTMX provides a powerful extension system that allows you to add new features or modify existing behaviors. Let’s look at a couple of useful extensions:
### 6.2.1 JSON Encapsulation
The `json-enc` extension allows you to work with JSON data more easily:
```
```
This extension will automatically JSON-encode the data specified in `hx-vars` when making the request.
### 6.2.2 Client-Side Templates
The `client-side-templates` extension allows you to use client-side templating engines like Mustache:
```
```
This allows you to separate your HTML structure from your data, making your code more maintainable.
## 6.3 Web Sockets: Full-Duplex Communication
While SSE is great for server-to-client communication, Web Sockets allow for full-duplex communication. HTMX supports Web Sockets out of the box:
```
```
This sets up a Web Socket connection to `/api/chat`. The form will send messages over the socket, and incoming messages will be added to the `chat-messages` div.
## 6.4 Out-of-Band Swaps: Updating Multiple Elements
Sometimes you want to update multiple parts of your page with a single request. HTMX supports this with Out-of-Band (OOB) swaps:
```
Waiting for update...
Count: 0
```
On the server side, you can return OOB content like this:
```
Updated successfully!
Count: 1
```
HTMX will update both the `#message` div (the target of the request) and the `#count` div (specified as an OOB swap).
## 6.5 Security Considerations
As you build more complex applications with HTMX, it’s important to keep security in mind:
1. __CSRF Protection__: HTMX supports CSRF tokens out of the box. Just include a meta tag with your CSRF token:
```
```
HTMX will automatically include this token in all requests.
2. __XSS Prevention__: Always sanitize data on the server side before returning it to HTMX. Don’t trust client-side data.
3. __Content Security Policy (CSP)__: If you’re using a strict CSP, you may need to adjust it to allow HTMX to work properly. Specifically, you’ll need to allow inline scripts and styles.
## 6.6 Debugging HTMX Applications
HTMX provides several tools to help you debug your applications:
1. __htmx.logAll()__: Call this in the console to log all HTMX events.
2. __hx-indicator__: Use this attribute to show loading indicators, which can help you visualize request timing.
3. __Network Tab__: The browser’s network tab is invaluable for inspecting HTMX requests and responses.
4. __htmx-settling class__: HTMX adds this class to elements during content swaps, which can help you debug transition issues.
Here’s an example that combines several of these advanced techniques:
```
```
This example sets up a WebSocket connection to a dashboard API, uses JSON encoding for the refresh action, and enables full HTMX logging for debugging.
By mastering these advanced techniques, you’ll be able to create sophisticated, real-time web applications with HTMX. In the next chapter, we’ll explore how HTMX fits into the broader web development ecosystem.
# 7 The HTMX Ecosystem
As we become more proficient with HTMX, let’s explore how it fits into the broader web development ecosystem. This chapter will dive into how HTMX integrates with popular frameworks, best practices for styling dynamic content, and strategies for testing and debugging HTMX applications.
## 7.1 Integrating HTMX with Popular Frameworks
HTMX is framework-agnostic, meaning it can work alongside many popular web frameworks. Let’s look at how to integrate HTMX with some common choices:
### 7.1.1 HTMX with Express (Node.js)
HTMX works well with Node.js backends. Here’s a simple example using Express:
```
const express = require('express');
const app = express();
app.get('/get-data', (req, res) => {
res.send('
Hello from Express!
');
});
app.get('/', (req, res) => {
res.send(`
Loading...
`);
});
app.listen(3000, () => console.log('Server running on port 3000'));
```
### 7.1.2 HTMX with Flask
Flask’s lightweight nature makes it a great fit for HTMX applications:
```
from flask import Flask, render_template
app = Flask(__name__)
@app.route('/get-data')
def get_data():
return '
Hello from Flask!
'
@app.route('/')
def index():
return '''
Loading...
'''
if __name__ == '__main__':
app.run(debug=True)
```
### 7.1.3 HTMX with Go and Templ
For Go applications, Templ offers a type-safe alternative to traditional templating. Templ is a typed templating language that integrates seamlessly with Go and works exceptionally well with HTMX. It provides compile-time safety, autocompletion, and easy refactoring, making it an excellent choice for HTMX-powered applications.
Here’s an example of using Templ with HTMX in a Go application:
```
package main
import (
"net/http"
"github.com/a-h/templ"
)
templ indexPage() {
Loading...
}
templ getData() {
Hello from Go with Templ!
}
func main() {
http.Handle("/", templ.Handler(indexPage()))
http.Handle("/get-data", templ.Handler(getData()))
http.ListenAndServe(":8080", nil)
}
```
This example demonstrates how Templ allows you to write your HTML templates directly in Go, providing type safety and easier integration with HTMX attributes.
### 7.1.4 HTMX with Laravel
Laravel, a popular PHP framework, provides a robust foundation for building web applications and integrates well with HTMX. Laravel’s elegant syntax, powerful ORM, and built-in tools for routing and templating make it an excellent choice for server-side rendering, which complements HTMX’s approach to frontend interactivity.
Here’s a simple example of using Laravel with HTMX:
```
// routes/web.php
use App\Http\Controllers\DataController;
Route::get('/', function () {
return view('welcome');
});
Route::get('/get-data', [DataController::class, 'getData']);
// app/Http/Controllers/DataController.php
namespace App\Http\Controllers;
class DataController extends Controller
{
public function getData()
{
return '
Hello from Laravel!
';
}
}
// resources/views/welcome.blade.php
Loading...
```
This example demonstrates how Laravel’s routing, controllers, and Blade templating engine can be used in conjunction with HTMX to create dynamic, server-rendered applications with minimal JavaScript.
These examples demonstrate how HTMX can be integrated with various backend frameworks, allowing you to choose the technology stack that best fits your project needs.
## 7.2 Styling Dynamic Content
When working with HTMX, you’re often dynamically updating parts of your page. HTMX provides several classes and attributes that can help you style your dynamic content effectively. Let’s explore some HTMX-specific techniques:
### 7.2.1 1. HTMX-added Classes for Transitions and Indicators
HTMX adds several classes to elements during the request lifecycle. You can use these for smooth transitions:
```
.htmx-settling {
opacity: 0;
transition: opacity 0.3s ease-out;
}
.htmx-request {
opacity: 0.5;
}
.htmx-swapping {
opacity: 0;
}
```
These styles create a fade effect during HTMX requests and content swaps.
### 7.2.2 2. Using hx-indicator for Loading States
The `hx-indicator` attribute allows you to specify an element to show while a request is in flight:
```
Loading...
```
```
.htmx-indicator {
display: none;
}
.htmx-request .htmx-indicator {
display: inline-block;
}
```
This example shows a loading spinner only while the request is in progress.
### 7.2.3 3. Styling Based on HTMX Request States
You can style elements differently based on the current HTMX request state:
```
.data-section {
transition: all 0.3s ease-out;
}
.data-section.htmx-request {
opacity: 0.5;
pointer-events: none;
}
.data-section.htmx-settling {
background-color: #f0f0f0;
}
```
This applies different styles during the request and settling phases.
### 7.2.4 4. Custom Class Swapping with hx-swap-class
The `hx-swap-class` attribute allows you to add or remove classes based on the request state:
```
Content here
```
```
.normal-state {
background-color: white;
}
.loading-state {
background-color: #f0f0f0;
opacity: 0.7;
}
```
This example swaps classes to visually indicate the loading state of the element.
These HTMX-specific styling techniques allow you to create smooth, responsive user interfaces that provide visual feedback during dynamic content updates.
## 7.3 Testing HTMX Applications
Testing HTMX applications involves both server-side and client-side testing. Here are some strategies:
### 7.3.1 Server-Side Testing
Let’s test our server endpoints as we would in any web application. We need to ensure they return the correct HTML fragments:
```
# Using pytest with Flask
def test_get_data(client):
response = client.get('/get-data')
assert response.status_code == 200
assert '
Hello from Flask!
' in response.data.decode('utf-8')
```
### 7.3.2 Client-Side Testing
For client-side testing, you can use tools like Cypress or Selenium to simulate user interactions:
```
// Using Cypress
describe('HTMX interactions', () => {
it('loads data on page load', () => {
cy.visit('/');
cy.get('[hx-get="/get-data"]').should('contain', 'Hello from Flask!');
});
});
```
## 7.4 Debugging HTMX Applications
Debugging HTMX applications requires a combination of server-side and client-side techniques:
### 7.4.1 Server-Side Debugging
Use your server framework’s debugging tools as usual. For example, with Django:
```
import logging
logger = logging.getLogger(__name__)
def get_data(request):
logger.debug('get_data called')
# ... rest of the view
```
### 7.4.2 Client-Side Debugging
Let’s explore HTMX’s tools for client-side debugging:
1. Use `htmx.logAll()` to log all HTMX events to the console.
2. Use the `hx-indicator` attribute to visualize when requests are in progress.
3. Use your browser’s developer tools to inspect network requests and responses.
```
Loading...
```
## 7.5 Performance Considerations
When building HTMX applications, consider these performance tips:
1. Use `hx-trigger` with delays to debounce frequent events like keyup.
2. Use `hx-target` to update only the necessary parts of the page.
3. Consider using `hx-boost` for traditional navigation when full page loads are acceptable.
4. Use server-side caching to speed up repeated requests.
Here’s an example combining several of these techniques:
```
Searching...
```
This input will trigger a search request 500ms after the user stops typing, update only the search results div, and show a loading indicator during the request.
By understanding how HTMX fits into the broader web development ecosystem, we can leverage its power while still using familiar tools and frameworks. In the next chapter, we’ll explore how to use HTMX to implement client-side routing, further enhancing the capabilities of your web applications.
# 8 Glossary of HTMX Terms and Attributes
## 8.1 Core Attributes
These attributes form the foundation of HTMX functionality, defining basic request types and behavior.
- `hx-get`: Triggers an HTTP GET request
- `hx-post`: Triggers an HTTP POST request
- `hx-put`: Triggers an HTTP PUT request
- `hx-delete`: Triggers an HTTP DELETE request
- `hx-patch`: Triggers an HTTP PATCH request
- `hx-trigger`: Specifies the event that triggers the HTMX request
- `hx-target`: Specifies where to insert the response
- `hx-swap`: Specifies how to swap the response into the DOM
## 8.2 Request Customization
These attributes allow you to customize the details of HTMX requests.
- `hx-params`: Specifies which parameters to submit with the request
- `hx-headers`: Adds custom headers to the request
- `hx-include`: Includes additional data in the request
- `hx-vals`: Adds extra values to the parameters
## 8.3 Response Handling
These attributes control how HTMX processes and displays the response from the server.
- `hx-select`: Allows you to select a subset of the response to be swapped in
- `hx-indicator`: Specifies an element to show while the request is in flight
## 8.4 Events and Lifecycle
These events allow you to hook into different stages of the HTMX request lifecycle.
- `htmx:load`: Event triggered when new content is loaded
- `htmx:configRequest`: Event triggered before the request is configured
- `htmx:beforeSend`: Event triggered before the request is sent
- `htmx:afterSettle`: Event triggered after the new content is settled
- `htmx:oobAfterSwap`: Event triggered for out-of-band swaps after the main response is processed
- `htmx:beforeSwap`: Event triggered before the swap is performed
## 8.5 Miscellaneous Features
These attributes provide additional functionality for specific use cases.
- `hx-boost`: Progressively enhances links and forms
- `hx-push-url`: Pushes the URL into the browser history stack
- `hx-confirm`: Shows a confirm dialog before issuing the request
- `hx-validate`: Forces validation of form inputs before a request
- `hx-sync`: Synchronizes HTMX requests
- `hx-history`: Controls history snapshot creation
- `hx-disable`: Disables HTMX processing on an element
- `hx-prompt`: Shows a prompt before making a request
- `hx-sse`: Used for server-sent events
- `hx-ws`: Used for WebSocket connections
- `hx-ext`: Used to include HTMX extensions
For a comprehensive list, please refer to the [the official HTMX reference](https://htmx.org/reference/).
# 9 Conclusion
## 9.1 Best Use Cases
HTMX excels in: - Server-rendered applications needing interactivity - Traditional web apps requiring modern features - Rapid prototyping and small to medium projects - Performance-critical applications
## 9.2 Key Strengths
- Simple, declarative syntax
- Server-side focused architecture
- Progressive enhancement support
- Minimal JavaScript
- SEO-friendly
## 9.3 Limitations
- Limited client-side state management
- Not suited for offline-first apps
- May not fit heavy client processing needs
- Learning curve for backend developers
- Smaller ecosystem than major frameworks
## 9.4 Looking Forward
HTMX offers a simpler alternative to complex JavaScript frameworks, focusing on HTML enhancement and server communication. Choose HTMX when server-side rendering and simple interactivity meet your needs. Consider alternatives for complex state management or offline requirements.
# 10 Not Covered In This Book
This book provides a solid foundation for working with HTMX, but there are some advanced topics and features that are not covered in detail. Here are some important topics you may want to explore in the official documentation:
## 10.1 Server-Side Templates
- [Server-Side Template Integration](https://htmx.org/server-side-templates/) - How to integrate HTMX with various server-side templating systems
## 10.2 Advanced Features
- [Path Dependencies](https://htmx.org/attributes/hx-path-deps/) - Managing dependencies between different paths in your application
- [Request/Response Headers](https://htmx.org/reference/#request_headers) - Complete list of HTMX-specific headers
- [View Transitions API](https://htmx.org/attributes/hx-swap/#view-transitions) - Using the experimental View Transitions API
- [Middleware](https://htmx.org/middleware/) - Server-side middleware patterns for HTMX
- [Response Headers](https://htmx.org/reference/#response_headers) - Special response headers for enhanced control
## 10.3 Extensions
- [Extension List](https://htmx.org/extensions/) - Complete list of available extensions
- [Creating Extensions](https://htmx.org/extensions/creating/) - How to create your own HTMX extensions
- [Client-Side Templates](https://htmx.org/extensions/client-side-templates/) - Using client-side templating
- [Server-Sent Events](https://htmx.org/extensions/sse/) - Real-time updates with SSE
- [WebSockets](https://htmx.org/extensions/ws/) - Real-time bidirectional communication
## 10.4 Advanced Patterns
- [Lazy Loading](https://htmx.org/examples/lazy-load/) - Loading content on demand
- [Infinite Scroll](https://htmx.org/examples/infinite-scroll/) - Implementing infinite scrolling
- [Active Search](https://htmx.org/examples/active-search/) - Real-time search functionality
- [Dialogs](https://htmx.org/examples/dialogs/) - Working with modal dialogs
- [File Upload](https://htmx.org/examples/file-upload/) - Handling file uploads with progress indicators
## 10.5 Integration
- [Alpine.js Integration](https://htmx.org/essays/alpine-vs-htmx/) - Using HTMX with Alpine.js
- [REST](https://htmx.org/essays/rest-explained/) - Understanding REST in the context of HTMX
- [Hypermedia APIs](https://htmx.org/essays/hypermedia-apis/) - Building hypermedia-driven APIs
## 10.6 Security
- [Security Guide](https://htmx.org/docs/#security) - Comprehensive security considerations
- [CSRF Protection](https://htmx.org/docs/#csrf) - Cross-Site Request Forgery protection
- [Content Security Policy](https://htmx.org/docs/#content-security-policy) - CSP configuration
For more detailed information on any of these topics, please refer to the [official HTMX documentation](https://htmx.org/docs/).
Thanks for reading. [Follow me on twitter](https://x.com/weloveoov).
# 11 Change log
April 2025 - Updated a few examples using the new HTMX extensions Dec 2024 - Fresh look. Updated chapters on error handling.